package cn.com.dstz.agent.config;

import java.util.Map;

public class CategoryConfig extends AgentConfig{
	
	public CategoryConfig( Map< String, Object > admin, int count ){
		super( admin, count , AgentConfig.CONFIG_CATEGORY  );
	}

	@Override
	public String getSQL( ) {
		
		if( this.getReturnValue( ).equals( SELF )){
			valueMap.put( "aid", admin.get( "id" ) );
			return " and c.adminid =:aid";
		}else if( this.getReturnValue( ).equals( ALL ) ){
			valueMap.put( "aid", admin.get( "topaid" ) );
			return " and c.aid = :aid";
		}
		
		valueMap.put( "topaid", admin.get( "topaid" ) );
		valueMap.put( "aid", admin.get( "id" ) );
		
		return getDefinedSQL( );
		
		
	}
	
	@Override
	public String getDefinedSQL( ) {
		String beginSQL = " and ( c.adminid in( select id from dstzadmin where ";
		String endSQL = " and topaid = :topaid ) or c.adminid=:aid)";
		return beginSQL +  super.getDefinedSQL( ) + endSQL ;
	}
	
	
	
}
